// 主题工具
export type ThemeMode = 'light' | 'dark' | 'auto'

export interface ThemeConfig {
  mode: ThemeMode
  primaryColor: string
  backgroundColor: string
  textColor: string
  borderColor: string
}

export class ThemeUtils {
  static getSystemTheme(): 'light' | 'dark' {
    if (typeof window !== 'undefined' && window.matchMedia) {
      return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
    }
    return 'light'
  }

  static applyTheme(theme: ThemeMode): void {
    const actualTheme = theme === 'auto' ? this.getSystemTheme() : theme
    document.documentElement.setAttribute('data-theme', actualTheme)
  }

  static getThemeConfig(theme: ThemeMode): ThemeConfig {
    const actualTheme = theme === 'auto' ? this.getSystemTheme() : theme
    
    if (actualTheme === 'dark') {
      return {
        mode: actualTheme,
        primaryColor: '#007AFF',
        backgroundColor: '#1C1C1E',
        textColor: '#FFFFFF',
        borderColor: '#38383A'
      }
    }
    
    return {
      mode: actualTheme,
      primaryColor: '#007AFF',
      backgroundColor: '#FFFFFF',
      textColor: '#000000',
      borderColor: '#E5E5E7'
    }
  }
}

export default ThemeUtils